package com.vint.mi;


/**
 * 求数值的反向值, 这里的反向指的是二进制的反向
 * 输入32位无符号数
 */
public class Mi33 {
    public static String solution(String line){
    	String[] src = line.split(" ");
    	int n = Integer.parseInt(src[0]);
	    int m = Integer.parseInt(src[1]);
	    return String.valueOf(minLeap(n,m));
    }

    public static int minLeap(int n, int m){
	    if(n>=m)return n-m;
        if(n*2==m)return 1;
        if(n==1)return minLeap(2,m)+1;
        int t1 = minLeap(n-1,m);
	    int t2 = minLeap(n*2,m);
	    if(t1<t2)return t1+1;
	    return t2+1;
    }
    public static void main(String[] args) {
        System.out.println(solution("7 60"));
    }
}
